#include "Camera.h"
#include "Bat.h"

CCamera::CCamera(CBat* pBat)
	:m_pBatAttached(pBat)
{
	m_bDynamic = true;
}

CCamera::~CCamera(void)
{
}

void CCamera::SetViewport(int iX, int iY, int iWidth, int iHeight)
{
	m_rectViewport.left = iX;
	m_rectViewport.bottom = iY;
	m_rectViewport.right = iWidth;
	m_rectViewport.top = iHeight;
}

int CCamera::Update()
{
	if(m_pBatAttached)
	{
		//if camera is attached to player
		if(m_bDynamic){
			//if dynamic cameras are enabled, update camera position
			const double* dBatPos = m_pBatAttached->GetPosition();

			m_f3Position.x = (float)dBatPos[0];
			m_f3Target.x = (float)dBatPos[0] * 0.5f;
		}
		else
		{
			//if dynamic cameras are disabled, reset x-pos to center
			m_f3Position.x = 0.0f;
			m_f3Target.x = 0.0f;
		}
	}
	return 0;	//OK
}